<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="DistributionJobDayService" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="708bbb08-1582-46b9-b6d9-4682940a0049">
	<property name="ireport.zoom" value="1.0"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<parameter name="sdate" class="java.lang.String"/>
	<parameter name="date" class="java.util.Date"/>
	<parameter name="service" class="java.lang.String"/>
	<parameter name="service_id" class="java.lang.Long">
		<defaultValueExpression><![CDATA[]]></defaultValueExpression>
	</parameter>
	<queryString>
		<![CDATA[(SELECT '00' AS H, COUNT(*) AS C, AVG(client_wait_period) AS AVG FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 00:00:00' AND '$P!{sdate} 01:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '01', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 01:00:00' AND '$P!{sdate} 02:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '02', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 02:00:00' AND '$P!{sdate} 03:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '03', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 03:00:00' AND '$P!{sdate} 04:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '04', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 04:00:00' AND '$P!{sdate} 05:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '05', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 05:00:00' AND '$P!{sdate} 06:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '06', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 06:00:00' AND '$P!{sdate} 07:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '07', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 07:00:00' AND '$P!{sdate} 08:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '08', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 08:00:00' AND '$P!{sdate} 09:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '09', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 09:00:00' AND '$P!{sdate} 10:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '10', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 10:00:00' AND '$P!{sdate} 11:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '11', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 11:00:00' AND '$P!{sdate} 12:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '12', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 12:00:00' AND '$P!{sdate} 13:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '13', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 13:00:00' AND '$P!{sdate} 14:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '14', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 14:00:00' AND '$P!{sdate} 15:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '15', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 15:00:00' AND '$P!{sdate} 16:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '16', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 16:00:00' AND '$P!{sdate} 17:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '17', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 17:00:00' AND '$P!{sdate} 18:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '18', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 18:00:00' AND '$P!{sdate} 19:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '19', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 19:00:00' AND '$P!{sdate} 20:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '20', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 20:00:00' AND '$P!{sdate} 21:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '21', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 21:00:00' AND '$P!{sdate} 22:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '22', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 22:00:00' AND '$P!{sdate} 23:00:00' AND service_id=$P{service_id}) UNION ALL
(SELECT '23', COUNT(*), AVG(client_wait_period) FROM statistic WHERE state_in<>0 AND  client_stand_time BETWEEN '$P!{sdate} 23:00:00' AND '$P!{sdate} 23:59:59' AND service_id=$P{service_id})]]>
	</queryString>
	<field name="H" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="C" class="java.lang.Integer">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="AVG" class="java.lang.Double">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<variable name="amount" class="java.lang.Integer" calculation="Sum">
		<variableExpression><![CDATA[$F{C}]]></variableExpression>
		<initialValueExpression><![CDATA[new java.lang.Integer(0)]]></initialValueExpression>
	</variable>
	<variable name="AVGSUM" class="java.lang.Double" calculation="Sum">
		<variableExpression><![CDATA[new java.lang.Double($F{AVG}.doubleValue()*$F{C}.doubleValue())]]></variableExpression>
	</variable>
	<title>
		<band height="89">
			<line>
				<reportElement uuid="673bdcd6-fd2b-40f7-aeb1-b44587e7265c" x="0" y="8" width="555" height="1"/>
			</line>
			<line>
				<reportElement uuid="509e5a57-650d-4f00-b1e8-57f0fe83918a" positionType="FixRelativeToBottom" x="0" y="81" width="555" height="1"/>
			</line>
			<staticText>
				<reportElement uuid="c5706eb5-df85-4776-968b-ad93f54d812c" x="1" y="9" width="551" height="24"/>
				<textElement textAlignment="Center">
					<font fontName="SansSerif" size="18" isBold="true" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<text><![CDATA[Распределение среднего времени ожидания]]></text>
			</staticText>
			<textField>
				<reportElement uuid="57a1cbd2-340e-428f-859a-3d69dad64d33" x="1" y="33" width="551" height="24"/>
				<textElement textAlignment="Center">
					<font fontName="SansSerif" size="18" isBold="true" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA[" внутри дня для услуги \"" + $P{service} + "\""]]></textFieldExpression>
			</textField>
			<textField pattern="">
				<reportElement uuid="47e2348d-8177-4636-824a-5d8bc58604fc" x="1" y="57" width="551" height="24"/>
				<textElement textAlignment="Center">
					<font fontName="SansSerif" size="18" isBold="true" isUnderline="false" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA["на дату " + (new java.text.SimpleDateFormat("dd.MM.yyyy")).format($P{date})]]></textFieldExpression>
			</textField>
		</band>
	</title>
	<pageHeader>
		<band/>
	</pageHeader>
	<columnHeader>
		<band height="393">
			<barChart>
				<chart isShowLegend="false" evaluationTime="Report">
					<reportElement uuid="15b557a3-92aa-4578-b733-35568870c95c" x="0" y="0" width="555" height="340"/>
					<chartTitle/>
					<chartSubtitle>
						<font fontName="SansSerif" size="14" isBold="false" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
					</chartSubtitle>
					<chartLegend/>
				</chart>
				<categoryDataset>
					<categorySeries>
						<seriesExpression><![CDATA[new java.lang.Integer(1)]]></seriesExpression>
						<categoryExpression><![CDATA[$F{H}]]></categoryExpression>
						<valueExpression><![CDATA[$F{AVG}]]></valueExpression>
					</categorySeries>
				</categoryDataset>
				<barPlot isShowTickMarks="false">
					<plot/>
					<itemLabel color="#000000" backgroundColor="#FFFFFF"/>
					<categoryAxisLabelExpression><![CDATA["часы"]]></categoryAxisLabelExpression>
					<categoryAxisFormat>
						<axisFormat/>
					</categoryAxisFormat>
					<valueAxisLabelExpression><![CDATA["среднее время ожидания, мин."]]></valueAxisLabelExpression>
					<valueAxisFormat>
						<axisFormat/>
					</valueAxisFormat>
				</barPlot>
			</barChart>
			<textField evaluationTime="Report">
				<reportElement uuid="e03b9f80-5013-4d9c-a8b4-15116cbef475" x="1" y="340" width="554" height="20"/>
				<textElement textAlignment="Center">
					<font size="12" isBold="true" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA["Среднее время ожидания для данной услуги за день - " + ($V{amount}.intValue() == 0 ? 0 : new java.lang.Double($V{AVGSUM}.doubleValue()/$V{amount}.doubleValue()).intValue())  + " мин."]]></textFieldExpression>
			</textField>
		</band>
	</columnHeader>
	<pageFooter>
		<band height="21">
			<textField evaluationTime="Report" pattern="" isBlankWhenNull="false">
				<reportElement uuid="524d3c3c-0640-4a2f-b295-5a6fdc1b62b8" key="textField" x="516" y="2" width="36" height="19" forecolor="#000000" backcolor="#FFFFFF"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement>
					<font fontName="SansSerif" size="10" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA["" + $V{PAGE_NUMBER}]]></textFieldExpression>
			</textField>
			<textField pattern="" isBlankWhenNull="false">
				<reportElement uuid="f442c387-7014-4ff6-84f7-80eea5b20297" key="textField" x="296" y="2" width="216" height="19" forecolor="#000000" backcolor="#FFFFFF"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement textAlignment="Right">
					<font fontName="SansSerif" size="10" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA["Страница " + $V{PAGE_NUMBER} + " из "]]></textFieldExpression>
			</textField>
			<textField pattern="" isBlankWhenNull="false">
				<reportElement uuid="0f4bdaf4-7b4c-4156-a659-6c0eb8b87c7b" key="textField" x="1" y="2" width="209" height="19" forecolor="#000000" backcolor="#FFFFFF"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement>
					<font fontName="SansSerif" size="10" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA[new Date()]]></textFieldExpression>
			</textField>
		</band>
	</pageFooter>
</jasperReport>
